Skip to content

fix GraphQL pagination - #115

Open
ryohidaka wants to merge 2 commits into
yusukebe:masterfrom
ryohidaka:bugfix/graphql-pagination
Open

ryohidaka wants to merge 2 commits into
yusukebe:masterfrom
ryohidaka:bugfix/graphql-pagination

Conversation

@ryohidaka

@ryohidaka ryohidaka commented Nov 2, 2026 •

Copy link
Copy Markdown

概要

GraphQL APIでページネーションが効かず、10件以上を取得できない不具合を修正

不具合理由

上限を指定せずに listShops() を呼び出していたことで、デフォルト上限である先頭10件のみがページネーションの対象になっていました。

対応内容

  • ショップ一覧をすべて取得する listAllShops を追加
  • GraphQLのページネーションで、カーソルを適用する前に全ショップを対象とするよう修正
  • デフォルト上限(10件)を超えるケースの回帰テストを追加

動作確認

手元で動作確認した結果は#115 (comment) に記載

備考

REST APIの挙動に変更はありません。

@ryohidaka ryohidaka changed the title fix: GraphQL pagination for all shops fix: fetch all shops for GraphQL pagination Nov 2, 2026
@ryohidaka
ryohidaka marked this pull request as draft November 2, 2026 15:37
@ryohidaka
ryohidaka force-pushed the bugfix/graphql-pagination branch from 30ca86e to 1b41eea Compare November 2, 2026 15:38
@ryohidaka
ryohidaka marked this pull request as ready for review November 2, 2026 15:38
@ryohidaka ryohidaka changed the title fix: fetch all shops for GraphQL pagination fix GraphQL pagination Nov 9, 2026
@ryohidaka
ryohidaka marked this pull request as draft November 18, 2026 11:32
@ryohidaka
ryohidaka force-pushed the bugfix/graphql-pagination branch from 1b41eea to cc1bd5f Compare November 18, 2026 11:52
@ryohidaka

ryohidaka commented Nov 18, 2026 •

Copy link
Copy Markdown
Author

動作確認結果

11/18時点のデータ数が104件

find content/shops -mindepth 1 -maxdepth 1 -type d | wc -l

     104

修正前

first: 100を指定した場合も、最初の10件のみ取得
totalCountも10件となる

curl -s https://ramen-api.dev/graphql \
  -H 'Content-Type: application/json' \
  -d '{
    "query": "{ shops(first: 100) { totalCount edges { node { id } } pageInfo { hasNextPage } } }"
  }' \
  | jq '{
      totalCount: .data.shops.totalCount,
      count: (.data.shops.edges | length),
      hasNextPage: .data.shops.pageInfo.hasNextPage
    }'
{
  "totalCount": 10,
  "count": 10,
  "hasNextPage": false
}

修正後 (ローカル)

first: 100を指定した場合は100件分取得できる。
totalCountは104件と全件取得できる。

curl -s http://localhost:8787/graphql \
  -H 'Content-Type: application/json' \
  -d '{
    "query": "{ shops(first: 100) { totalCount edges { node { id } } pageInfo { hasNextPage } } }"
  }' \
  | jq '{
      totalCount: .data.shops.totalCount,
      count: (.data.shops.edges | length),
      hasNextPage: .data.shops.pageInfo.hasNextPage
    }'
{
  "totalCount": 104,
  "count": 100,
  "hasNextPage": true
}

@ryohidaka
ryohidaka marked this pull request as ready for review November 18, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant